package com.starblink.search.result.ui

import com.starblink.android.basic.base.BaseViewModel

internal class SearchResultVM : BaseViewModel() {

    var keyword: String? = null

    var composeWords: List<String>? = null

    val wordForQuery: String
        get() {
            return if (composeWords?.isNotEmpty() == true) {
                val strBuilder = StringBuilder()
                composeWords?.forEachIndexed { index, s ->
                    strBuilder.append(s)
                    index.takeIf { it < composeWords!!.size - 1 }?.run {
                        strBuilder.append(" ")
                    }
                }
                strBuilder.toString()
            } else if (keyword?.isNotEmpty() == true) {
                keyword!!
            } else {
                ""
            }
        }

}